<template>
	<view>
		<template>
			<view>
				<view class="item">
					<view class="top">
						<view class="name">{{ siteList.name }}</view>
						<view class="phone">{{ siteList.site }}</view>
						<view class="tag">
							<text v-for="(item, index) in siteList.tag" :key="index"
								:class="{red:item.tagText=='默认'}">{{ item.tagText }}</text>
							<u-icon name="edit-pen" :size="40" color="#999999" @tap="toAddSite"></u-icon>
						</view>
					</view>
				</view>
			</view>
		</template>
		<!-- 注意，如果需要兼容微信小程序，最好通过setRules方法设置rules规则 -->
		<u-form labelPosition="left" :model="model1" :rules="rules" ref="form1" labelWidth="100" class="formZC">
			<u-form-item wit label="快递地址" labelWidth="100" prop="userInfo.name" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.name" border="none"></u--input>
			</u-form-item>
			<u-form-item label="送达时间" prop="userInfo.sex" borderBottom @click="showSex = true;" ref="item1">
				<u--input v-model="model1.userInfo.sex" disabled disabledColor="#ffffff" placeholder="请选择性别"
					border="none"></u--input>
				<u-icon slot="right" name="arrow-right"></u-icon>
			</u-form-item>
			<u-form-item label="取件信息" prop="userInfo.name" borderBottom ref="item1">
				<u--input v-model="model1.userInfo.name" border="none"></u--input>
			</u-form-item>
			<u-form-item label="备注" prop="userInfo.name" borderBottom ref="item1">
				<u--textarea v-model="userInfo.name" placeholder="请输入内容"></u--textarea>
			</u-form-item>
		</u-form>
		<u-action-sheet :show="showSex" :actions="actions" title="请选择性别" description="如果选择保密会报错"
			@close="showSex = false" @select="sexSelect">
		</u-action-sheet>
		<submitBar></submitBar>
	</view>
</template>

<script>
	import submitBar from "../../template/submitBar/index.vue"
	export default {
		components: {
			submitBar
		},
		data() {
			return {
				siteList: {
					id: 1,
					name: '张成',
					phone: '183****5523',
					tag: [{
							tagText: '默认'
						},
						{
							tagText: '科技学院'
						}
					],
					site: 'B3132'
				},
				showSex: false,
				model1: {
					userInfo: {
						name: 'uView UI',
						sex: '',
					},
				},
				actions: [{
						name: '男',
					},
					{
						name: '女',
					},
					{
						name: '保密',
					},
				],
				rules: {
					'userInfo.name': {
						type: 'string',
						required: true,
						message: '请填写姓名',
						trigger: ['blur', 'change']
					},
					'userInfo.sex': {
						type: 'string',
						max: 1,
						required: true,
						message: '请选择男或女',
						trigger: ['blur', 'change']
					},
				},
				radio: '',
				switchVal: false
			}
		},
		methods: {
			toAddSite() {
				uni.navigateTo({
					url: '/pages/core/address/addSite'
				});
			},
			sexSelect(e) {
				this.model1.userInfo.sex = e.name
				this.$refs.form1.validateField('userInfo.sex')
			},
		}
	}
</script>

<style lang="scss" scoped>
	.u-form-item {
		padding: 40rpx 20rpx !important;

	}

	.item {

		width: 710rpx;
		background-color: #ff7900;
		margin: 20rpx auto;
		border-radius: 20rpx;
		box-sizing: border-box;
		font-size: 28rpx;
		padding: 40rpx 20rpx;

		.top {
			display: flex;
			font-weight: bold;
			font-size: 34rpx;

			.phone {
				margin-left: 60rpx;
			}

			.tag {
				display: flex;
				font-weight: normal;
				// align-items: center;

				text {
					display: block;
					width: 100rpx;
					height: 40rpx;
					line-height: 40rpx;
					color: #ffffff;
					font-size: 20rpx;
					border-radius: 6rpx;
					text-align: center;
					margin-left: 30rpx;
					background-color: rgb(49, 145, 253);
				}

				.red {
					background-color: red
				}
			}
		}

		.bottom {
			display: flex;
			margin-top: 20rpx;
			font-size: 28rpx;
			justify-content: space-between;
			color: #999999;
		}
	}
</style>
